package org.wyn.service.impl;

import java.util.List;

import org.wyn.mongodb.bean.FreshThing;
import org.wyn.mongodb.dao.impl.FreshThingDao;
import org.wyn.mongodb.dao.impl.FriendRelationshipDao;
import org.wyn.service.IFreshThingService;

import com.google.inject.Inject;
/**
 * 新鲜事service实现层
 * @author wyn
 *
 */
public class FreshThingServiceImpl implements IFreshThingService{

	@Override
	public List<FreshThing> findByOwner(String ownerUserName) {
		return freshThingDao.createQuery().filter("userName",ownerUserName).order("-createTime").asList();
	}
	@Override
	public List<FreshThing> findThingOfFrindAndSelf(String userName) {
		List<String> users = friendRelationshipDao.findRelationshipByUser(userName);
		users.add(userName);
		return freshThingDao.createQuery().filter("userName in",users).order("-createTime").asList();
	}

	@Inject
	private FreshThingDao freshThingDao;
	@Inject
	private FriendRelationshipDao friendRelationshipDao;
	public FreshThingDao getFreshThingDao() {
		return freshThingDao;
	}
	public void setFreshThingDao(FreshThingDao freshThingDao) {
		this.freshThingDao = freshThingDao;
	}

	public FriendRelationshipDao getFriendRelationshipDao() {
		return friendRelationshipDao;
	}

	public void setFriendRelationshipDao(FriendRelationshipDao friendRelationshipDao) {
		this.friendRelationshipDao = friendRelationshipDao;
	}
}
